using System.Collections.Generic;
using JlPay.Sdk.Models;

namespace JlPay.Sdk.Models.Openmerch.Bill
{
    /// <summary>
    /// 结算账单查询请求
    /// @author liaochangyi
    /// @since 2025-01-25
    /// </summary>
    public class SettleBillQueryRequest : OrgBaseRequest
    {
        /// <summary>
        /// API URL
        /// </summary>
        public const string API_URL = "/open/bill/settle-bill/query";

        /// <summary>
        /// 商户号
        /// </summary>
        public string? MerchNo { get; set; }

        /// <summary>
        /// 开始营业日期，订单交易日期（订单交易日期/订单清算日期，二选一），结束时间减开始时间不能超过30天， yyyy-MM-dd
        /// </summary>
        public string? StartBusiDate { get; set; }

        /// <summary>
        /// 结束营业日期，订单交易日期（订单交易日期/订单清算日期，二选一），结束时间减开始时间不能超过30天， yyyy-MM-dd
        /// </summary>
        public string? EndBusiDate { get; set; }

        /// <summary>
        /// 开始结算日期，订单结算日期（订单交易日期/订单清算日期，二选一）， yyyy-MM-dd
        /// </summary>
        public string? StartSettleDate { get; set; }

        /// <summary>
        /// 结束结算日期，订单结算日期（订单交易日期/订单清算日期，二选一）， yyyy-MM-dd
        /// </summary>
        public string? EndSettleDate { get; set; }

        /// <summary>
        /// 付款状态，0-待付款 1-付款成功 2-付款失败 3-无需付款
        /// </summary>
        public string? PayStatus { get; set; }

        /// <summary>
        /// 转换为字典
        /// </summary>
        /// <returns>字典数据</returns>
        public Dictionary<string, object> ToDictionary()
        {
            var data = new Dictionary<string, object>();

            // 添加基础字段
            if (!string.IsNullOrEmpty(OrgNo))
            {
                data["org_no"] = OrgNo;
            }
            if (!string.IsNullOrEmpty(base.MerchNo))
            {
                data["merch_no"] = base.MerchNo;
            }

            // 添加业务字段
            if (!string.IsNullOrEmpty(MerchNo))
            {
                data["merch_no"] = MerchNo;
            }
            if (!string.IsNullOrEmpty(StartBusiDate))
            {
                data["start_busi_date"] = StartBusiDate;
            }
            if (!string.IsNullOrEmpty(EndBusiDate))
            {
                data["end_busi_date"] = EndBusiDate;
            }
            if (!string.IsNullOrEmpty(StartSettleDate))
            {
                data["start_settle_date"] = StartSettleDate;
            }
            if (!string.IsNullOrEmpty(EndSettleDate))
            {
                data["end_settle_date"] = EndSettleDate;
            }
            if (!string.IsNullOrEmpty(PayStatus))
            {
                data["pay_status"] = PayStatus;
            }

            return data;
        }
    }
} 